using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
class Program
{
    static void Main()
    {
        //int[] numbers = { 255, 255, 255, 255, 255, 255, 255, 254 };
 
        int[] numbers = new int[8];
 
        for (int i = 0; i < 8; i++)
        {
            numbers[i] = int.Parse(Console.ReadLine());
        }
         
 
        int[,] notsortedarray = new int[8, 8];
        int[,] sortedarray = new int[8, 8];
         
        int[] results = new int[8];
 
        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                notsortedarray[i, j] = numbers[i] % 2;
                numbers[i] /= 2;
            }
        }
 
 
        for (int i = 0; i < 8; i++)
        {
            int counter = 0;
 
            for (int j = 0; j < 8; j++)
            {
                if (notsortedarray[j, i] == 1)
                {
                    counter++;
                }
            }
 
            for (int j = 0; j < counter; j++)
            {
                sortedarray[j, i] = 1;
            }
        }
 
 
        for (int i = 0; i < 8; i++)
        {
            int k = 0;
            double num = 0;
            for (int j = 0; j <8; j++)
            {               
                if (sortedarray[i, j] == 1)
                {
 
                    num = num+Math.Pow(2,j);
                    results[i]=(int)num;
                    k++;
                }
            }
        }
        for (int i = 7; i >= 0; i--)
        {
            Console.WriteLine(results[i]);
        } 
           
    }
 
    static void Print(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            for (int j = 0; j < array.GetLength(1); j++)
            {
                Console.Write(array[i, j]);
            }
            Console.WriteLine();
        }
    }
}